<style>
    [v-cloak] {
        display: none;
    }

    .info-wrap {
        padding-top: 10px;
        padding-bottom: 10px;
        width: 300px;
        border: 1px solid #eee;
        border-radius: 4px;
        margin-left: 275px;
    }

    .header-img {
        display: block;
        margin: 0 auto;
        width: 80px;
        height: 80px;
        border-radius: 50%;
    }

    .info-wrap h4 {
        text-align: center;
        font-size: 16px;

    }
</style>

<div class="row">
    <div class="col-md-12">
        <div class="box box-info">

            <!-- /.box-header -->
            <!-- form start -->
            <form action="" method="post" accept-charset="UTF-8" class="form-horizontal"
                  pjax-container="">
                <div class="box-body">
                    <div class="fields-group">
                        <div class="form-group ">
                            <label class="col-sm-2  control-label">超代ID</label>
                            <div class="col-sm-8">
                                <div class="box box-solid box-default no-margin">
                                    <!-- /.box-header -->
                                    <div class="box-body">
                                       哈哈哈
                                    </div>
                                    <!-- /.box-body -->
                                </div>
                            </div>
                        </div>
                        <div class="form-group ">
                            <label class="col-sm-2  control-label">超代昵称</label>
                            <div class="col-sm-8">
                                <div class="box box-solid box-default no-margin">
                                    <!-- /.box-header -->
                                    <div class="box-body">
                                        开机键进
                                    </div>
                                    <!-- /.box-body -->
                                </div>
                            </div>
                        </div>

                        <div class="form-group ">
                            <label class="col-sm-2  control-label">创建时间</label>
                            <div class="col-sm-8">
                                <div class="box box-solid box-default no-margin">
                                    <!-- /.box-header -->
                                    <div class="box-body">
                                        看大家都讲
                                    </div>
                                    <!-- /.box-body -->
                                </div>
                            </div>
                        </div>

                        <div class="form-group  ">
                            <label for="password" class="col-sm-2  control-label">设置超代登录密码</label>
                            <div class="col-sm-8">
                                <div class="input-group">
                                    <span class="input-group-addon"><i class="fa fa-eye-slash fa-fw"></i></span>
                                    <input type="password" id="password" name="password" value="" class="form-control password"
                                           placeholder="输入 密码"
                                           style="background-color: rgb(250, 255, 189) !important; box-shadow: none; color: rgb(0, 0, 0);">
                                </div>
                            </div>
                        </div>



                        <hr style="margin-top: 0px;">
                    </div>
                </div>
                <!-- /.box-body -->

                <div class="box-footer">
                    <input type="hidden" name="_token" value="{{ csrf_token() }}">
                    <div class="col-md-2">
                    </div>
                    <div class="col-md-8">
                        <div class="btn-group pull-right">
                            <button type="button" class="btn btn-primary submit" class="">提交</button>
                        </div>

                        <div class="btn-group pull-left">
                            <button type="reset" class="btn btn-warning">撤销</button>
                        </div>
                    </div>
                </div>
                <input type="hidden" name="_method" value="PUT" class="_method">
                <input type="hidden" name="_previous_" value="/admin/superagent/list" class="_previous_">
                <!-- /.box-footer -->
            </form>
        </div>

    </div>
</div>

<!-- 模态框（Modal） -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">提示</h4>
            </div>
            <div class="modal-body">
                <p>此超代账户余额为: <span> 和打个电话</span></p>
                <p>是否删除此超代?</p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-danger delete" data-dismiss="modal">确认删除</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>

<script>


        $('.submit').click(function(){
            var _aidList = [];
            for(let i = 0; i< instance.nextAgentList.length; i ++){
                _aidList.push(instance.nextAgentList[i].id)
            }

            var _data = {
                id:'{{ $user->id }}',
                password:$('#password').val(),
                percent:$('#percent').val(),
                super_child:_aidList,
                _token:'{{csrf_token()}}',
            }

            var submitButton = $(this);
            $.ajax({
                url:'/admin/superagent/list/user_update',
                type: 'post',
                dataType: 'json',
                data:_data,
                beforeSend: function () {
                    submitButton.attr('disabled', 'disabled');
                },
                success:function(data){
                    if (data.code != 0) {
                        instance.$message.error(data.msg)
                    } else {
                        instance.$message.success('修改成功');
                        document.location = "{{ admin_url("superagent/list") }}";
                    }
                    submitButton.removeAttr('disabled')
                },
                error:function(){
                    submitButton.removeAttr('disabled')
                }
            })
        })


    })
</script>